package com.by.service;

import com.by.mapper.ValidateCodeMapper;
import com.by.util.ValidateCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ValidateCodeServiceImpl implements ValidateCodeService {

    @Autowired
    private ValidateCodeMapper validateCodeMapper;

    @Override
    public void send4Order(String telephone) {
        //1.往手机端发送验证码
        Integer validateCode = ValidateCodeUtils.generateValidateCode(4);
        System.out.println("往" + telephone + "发送验证码" + validateCode);
        //2.把验证码保存到数据库
        validateCodeMapper.addValidateCode(telephone, validateCode, new Date());
    }

}
